/**
 * @description 反馈集中处理中间件
 */
class BaseModel {
	constructor(message, data) {
		if (typeof data == 'string') {
			this.message = data;
			data = null;
			message = null;
		}
		if (data) {
			this.data = data
		}
		if (message) {
			this.message = message
		}
	}
}

/**
 * 请求成功的model
 */
class SuccessModel extends BaseModel {
	constructor(data, message) {
		super(data, message);
		this.errno = 0;
		this.success = true;
	}
}
/**
 * 请求失败的model
 */
class ErrorModel extends BaseModel {
	constructor(data, message) {
		super(data, message)
		this.errno = -1;
		this.success = false;
	}
}

module.exports = {
	ErrorModel,
	SuccessModel,
}
